<template>
	<view class="content">
		<view class="u-page">
			<!-- 所有内容的容器 -->
			<view v-if="current == 0">
				<index></index>
			</view>
			<view v-if="current == 1">
				<msg></msg>
			</view>
			<view v-if="current == 3">
				<friend></friend>
			</view>
			<view v-if="current == 4">
				<user></user>
			</view>
		</view>
		<!-- 与包裹页面所有内容的元素u-page同级，且在它的下方 -->
		<u-tabbar v-model="current" :list="list" :mid-button="true" :before-switch="beforeSwitch"></u-tabbar>
	</view>
</template>

<script>
	import index  from '@/components/index.vue';
	import msg  from '@/components/msg.vue';
	import friend  from '@/components/friend.vue';
	import user  from '@/components/user.vue';
	export default {
		components:{
			index,
			msg,
			user
		},
		data() {
			return {
				list: [{
						iconPath: "home",
						selectedIconPath: "home-fill",
						text: '首页',
						count: 2,
						isDot: true,
						customIcon: false,
					},
					{
						iconPath: "photo",
						selectedIconPath: "photo-fill",
						text: '消息',
						count: 23,
						customIcon: false,
					},
					{
						iconPath: "https://cdn.uviewui.com/uview/common/min_button.png",
						selectedIconPath: "https://cdn.uviewui.com/uview/common/min_button_select.png",
						text: '直播',
						midButton: true,
						customIcon: false,
					},
					{
						iconPath: "play-right",
						selectedIconPath: "play-right-fill",
						text: '朋友',
						customIcon: false,
					},
					{
						iconPath: "account",
						selectedIconPath: "account-fill",
						text: '我的',
						isDot: false,
						customIcon: false,
					},
				],
				current: 0
			}
		},
		onLoad() {

		},
		methods: {
			beforeSwitch(index) {
				console.log(index)
				this.current = index;
				if(index == 2){
					uni.redirectTo({
						url: '/pages/live/index'
					})
				}
				// 只能切换偶数项
				if(index % 2 == 0) return true;
				else return false;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		padding-top: 60rpx;
	}
</style>
